//颜色分类
class Solution {
public:
    int _sort(vector<int>& nums, int left, int right, int target) {
        int n = nums.size();
        while (right < n) {
            if (nums[right] < target) {
                swap(nums[left], nums[right]);
                left++;
            }
            right++;
        }
        return left;
    }
    void sortColors(vector<int>& nums) {
        int pos = _sort(nums, 0, 0, 1);
        _sort(nums, pos, pos, 2);
    }
};